/*
 Navicat Premium Data Transfer

 Source Server         : 127.0.0.1
 Source Server Type    : MySQL
 Source Server Version : 50639
 Source Host           : localhost:3306
 Source Schema         : api-gateway

 Target Server Type    : MySQL
 Target Server Version : 50639
 File Encoding         : 65001

 Date: 22/10/2022 15:47:44
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for http_statement
-- ----------------------------
-- ----------------------------
-- Table structure for application_interface
-- ----------------------------
DROP TABLE IF EXISTS `application_interface`;
CREATE TABLE `application_interface` (
                                         `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键',
                                         `system_id` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT '系统标识',
                                         `interface_id` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT '接口标识',
                                         `interface_name` varchar(128) COLLATE utf8_bin DEFAULT NULL COMMENT '接口名称',
                                         `interface_version` varchar(16) COLLATE utf8_bin DEFAULT NULL COMMENT '接口版本',
                                         `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                         `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                         PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

-- ----------------------------
-- Records of application_interface
-- ----------------------------
BEGIN;
INSERT INTO `application_interface` (`system_id`, `interface_id`, `interface_name`, `interface_version`)
VALUES
    ('sys001', 'interface001', '用户登录接口', 'v1.0'),
    ('sys001', 'interface002', '订单查询接口', 'v1.1'),
    ('sys002', 'interface003', '商品搜索接口', 'v2.0'),
    ('sys002', 'interface004', '支付接口', 'v1.2'),
    ('sys003', 'interface005', '用户注册接口', 'v1.0');

COMMIT;

-- ----------------------------
-- Table structure for application_interface_method
-- ----------------------------
DROP TABLE IF EXISTS `application_interface_method`;
CREATE TABLE `application_interface_method` (
                                                `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键',
                                                `system_id` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT '系统标识',
                                                `interface_id` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT '接口标识',
                                                `method_id` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT '方法标识',
                                                `method_name` varchar(128) COLLATE utf8_bin DEFAULT NULL COMMENT '方法名称',
                                                `parameter_type` varchar(256) COLLATE utf8_bin DEFAULT NULL COMMENT '参数类型；(RPC 限定单参数注册)；new String[]{"java.lang.String"}、new String[]{"cn.bugstack.gateway.rpc.dto.XReq"}',
                                                `uri` varchar(126) COLLATE utf8_bin DEFAULT NULL COMMENT '网关接口',
                                                `http_command_type` varchar(32) COLLATE utf8_bin DEFAULT NULL COMMENT '接口类型；GET、POST、PUT、DELETE',
                                                `auth` int(4) DEFAULT NULL COMMENT 'true = 1是、false = 0否',
                                                `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                                `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                                PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

-- ----------------------------
-- Records of application_interface_method
-- ----------------------------
BEGIN;
INSERT INTO `application_interface_method`
(`system_id`, `interface_id`, `method_id`, `method_name`, `parameter_type`, `uri`, `http_command_type`, `auth`)
VALUES
    ('sys001', 'interface001', 'method001', '获取用户信息', 'new String[]{"java.lang.String"}', '/api/user/info', 'GET', 1),
    ('sys001', 'interface002', 'method002', '创建订单', 'new String[]{"java.lang.String", "java.lang.Integer"}', '/api/order/create', 'POST', 1),
    ('sys002', 'interface003', 'method003', '商品搜索', 'new String[]{"cn.bugstack.gateway.rpc.dto.XReq"}', '/api/product/search', 'GET', 1),
    ('sys002', 'interface004', 'method004', '处理支付', 'new String[]{"java.lang.String", "java.lang.Double"}', '/api/payment/process', 'POST', 0),
    ('sys003', 'interface005', 'method005', '用户注册', 'new String[]{"java.lang.String", "java.lang.String"}', '/api/user/register', 'POST', 1);

COMMIT;

-- ----------------------------
-- Table structure for application_system
-- ----------------------------
DROP TABLE IF EXISTS `application_system`;
CREATE TABLE `application_system` (
                                      `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键',
                                      `system_id` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT '系统标识',
                                      `system_name` varchar(128) COLLATE utf8_bin DEFAULT NULL COMMENT '系统名称',
                                      `system_type` varchar(4) COLLATE utf8_bin DEFAULT NULL COMMENT '系统类型；RPC、HTTP',
                                      `system_registry` varchar(128) COLLATE utf8_bin DEFAULT NULL COMMENT '注册中心',
                                      `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                      `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                      PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

-- ----------------------------
-- Records of application_system
-- ----------------------------
BEGIN;
INSERT INTO `application_system`
(`system_id`, `system_name`, `system_type`, `system_registry`)
VALUES
    ('sys001', '用户管理系统', 'HTTP', 'http://registry.example.com'),
    ('sys002', '订单处理系统', 'RPC', 'rpc://registry.example.com'),
    ('sys003', '支付网关', 'HTTP', 'http://registry.example.com'),
    ('sys004', '商品搜索系统', 'RPC', 'rpc://registry.example.com'),
    ('sys005', '物流管理系统', 'HTTP', 'http://registry.example.com');

COMMIT;

-- ----------------------------
-- Table structure for gateway_distribution
-- ----------------------------
DROP TABLE IF EXISTS `gateway_distribution`;
CREATE TABLE `gateway_distribution` (
                                        `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键',
                                        `group_id` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT '分组标识',
                                        `gateway_id` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT '网关标识',
                                        `system_id` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT '系统标识',
                                        `system_name` varchar(128) COLLATE utf8_bin DEFAULT NULL COMMENT '系统名称',
                                        `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                        `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                        PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

-- ----------------------------
-- Records of gateway_distribution
-- ----------------------------
BEGIN;
INSERT INTO `gateway_distribution`
(`group_id`, `gateway_id`, `system_id`, `system_name`)
VALUES
    ('group001', 'gateway001', 'sys001', '用户管理系统'),
    ('group002', 'gateway002', 'sys002', '订单处理系统'),
    ('group003', 'gateway003', 'sys003', '支付网关'),
    ('group004', 'gateway004', 'sys004', '商品搜索系统'),
    ('group005', 'gateway005', 'sys005', '物流管理系统');

COMMIT;

-- ----------------------------
-- Table structure for gateway_server
-- ----------------------------
DROP TABLE IF EXISTS `gateway_server`;
CREATE TABLE `gateway_server` (
                                  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键',
                                  `group_id` varchar(32) COLLATE utf8_bin DEFAULT NULL COMMENT '分组标识',
                                  `group_name` varchar(128) COLLATE utf8_bin DEFAULT NULL COMMENT '分组名称',
                                  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

-- ----------------------------
-- Records of gateway_server
-- ----------------------------
BEGIN;
INSERT INTO `gateway_server`
(`group_id`, `group_name`)
VALUES
    ('group001', '管理后台'),
    ('group002', '支付服务'),
    ('group003', '商品搜索服务'),
    ('group004', '订单处理'),
    ('group005', '物流管理');

COMMIT;

-- ----------------------------
-- Table structure for gateway_server_detail
-- ----------------------------
DROP TABLE IF EXISTS `gateway_server_detail`;
CREATE TABLE `gateway_server_detail` (
                                         `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增主键',
                                         `group_id` varchar(32) COLLATE utf8_bin DEFAULT NULL COMMENT '分组标识',
                                         `gateway_id` varchar(32) COLLATE utf8_bin DEFAULT NULL COMMENT '网关标识',
                                         `gateway_name` varchar(128) COLLATE utf8_bin DEFAULT NULL COMMENT '网关名称',
                                         `gateway_address` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT '网关地址：127.0.0.1',
                                         `status` varchar(4) COLLATE utf8_bin DEFAULT NULL COMMENT '服务状态：0不可用、1可使用',
                                         `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                         `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                         PRIMARY KEY (`id`),
                                         UNIQUE KEY `idx_gateway` (`gateway_id`,`gateway_address`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

-- ----------------------------
-- Records of gateway_server_detail
-- ----------------------------
BEGIN;
INSERT INTO `gateway_server_detail`
(`group_id`, `gateway_id`, `gateway_name`, `gateway_address`, `status`)
VALUES
    ('group001', 'gateway001', '管理后台网关', '127.0.0.1', '1'),
    ('group002', 'gateway002', '支付服务网关', '192.168.1.1', '1'),
    ('group003', 'gateway003', '商品搜索网关', '192.168.1.2', '0'),
    ('group004', 'gateway004', '订单处理网关', '192.168.1.3', '1'),
    ('group005', 'gateway005', '物流管理网关', '192.168.1.4', '0');

COMMIT;

DROP TABLE IF EXISTS `http_statement`;
CREATE TABLE `http_statement` (
                                  `id` bigint(11) NOT NULL AUTO_INCREMENT,
                                  `application` varchar(128) COLLATE utf8_bin NOT NULL COMMENT '应用名称',
                                  `interface_name` varchar(256) COLLATE utf8_bin NOT NULL COMMENT '服务接口；RPC、其他',
                                  `method_name` varchar(128) COLLATE utf8_bin NOT NULL COMMENT ' 服务方法；RPC#method',
                                  `parameter_type` varchar(256) COLLATE utf8_bin NOT NULL COMMENT '参数类型(RPC 限定单参数注册)；new String[]{"java.lang.String"}、new String[]{"cn.bugstack.gateway.rpc.dto.XReq"}',
                                  `uri` varchar(128) COLLATE utf8_bin NOT NULL COMMENT '网关接口',
                                  `http_command_type` varchar(32) COLLATE utf8_bin NOT NULL COMMENT '接口类型；GET、POST、PUT、DELETE',
                                  `auth` int(4) NOT NULL DEFAULT '0' COMMENT 'true = 1是、false = 0否',
                                  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

-- ----------------------------
-- Records of http_statement
-- ----------------------------
BEGIN;
INSERT INTO `http_statement` VALUES (1, 'provider', 'com.lxc.common.HelloTestService', 'sayTestHi', 'java.lang.String', '/wg/activity/sayTestHi', 'GET', 0, '2022-10-22 15:30:00', '2022-10-22 15:30:00');
INSERT INTO `http_statement` VALUES (2, 'provider', 'com.lxc.common.HelloTestService', 'sayUserInfo', 'com.lxc.common.UserEntity', '/wg/activity/sayUserInfo', 'POST', 1, '2022-10-22 15:30:00', '2022-10-22 15:30:00');
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
